package com.basic.boot.common.model;

import java.io.Serializable;

/**
 * @author cherrish
 * @time 2019-04-28 11:24
 * @name RespBody
 * @desc:
 */
public class RespBody implements Serializable {

    private static final long serialVersionUID = -9018030473586265747L;

    private static final int SCODE_SUCCESS = 1;
    private static final int SCODE_FAIL = -1;

    private static final String SMSG_SUCCESS = "success";
    private static final String SMSG_FAIL = "success";

    private static final String SDATA_NULL = "{}";

    private final int scode;

    private final String smsg;

    private final Object sdata;

    private final long scurrtime;

    private RespBody(int scode, String smsg, Object sdata) {
        this.scode = scode;
        this.smsg = smsg;
        this.sdata = sdata;
        this.scurrtime = System.currentTimeMillis();
    }

    public static RespBody success(){
        return new RespBody(SCODE_SUCCESS, SMSG_SUCCESS, SDATA_NULL);
    }

    public static RespBody success(Object sdata){
        return new RespBody(SCODE_SUCCESS, SMSG_SUCCESS, sdata);
    }

    public static RespBody success(String smsg, Object sdata){
        return new RespBody(SCODE_SUCCESS, smsg, sdata);
    }


    public static RespBody fail(){
        return new RespBody(SCODE_FAIL, SMSG_FAIL, SDATA_NULL);
    }

    public static RespBody fail(Object sdata){
        return new RespBody(SCODE_FAIL, SMSG_FAIL, sdata);
    }

    public static RespBody fail(String smsg, Object sdata){
        return new RespBody(SCODE_FAIL, SMSG_FAIL, sdata);
    }
}
